<?php
/**
 * Shopware 5
 * Copyright (c) shopware AG
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Shopware" is a registered trademark of shopware AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */

namespace Shopware\Models\Widget;

use Doctrine\ORM\Mapping as ORM;
use Shopware\Components\Model\ModelEntity;

/**
 * @ORM\Table(name="s_core_widgets")
 * @ORM\Entity
 */
class Widget extends ModelEntity
{
    /**
     * @var int
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(name="name", type="string", nullable=false)
     */
    private $name;

    /**
     * @var string
     * @ORM\Column(name="label", type="string", nullable=false)
     *
     * @deprecated Will be removed in 5.5.
     */
    private $label;

    /**
     * @var
     * @ORM\OneToMany(targetEntity="Shopware\Models\Widget\View", mappedBy="widget")
     */
    private $views;

    /**
     * @var int
     * @ORM\Column(name="plugin_id", type="integer", nullable=true)
     */
    private $pluginId;

    /**
     * @var \Shopware\Models\Plugin\Plugin
     * @ORM\ManyToOne(targetEntity="Shopware\Models\Plugin\Plugin", inversedBy="widgets")
     * @ORM\JoinColumn(name="plugin_id", referencedColumnName="id")
     */
    private $plugin;

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @deprecated Will be removed in 5.5. Use 'label' snippet from 'backend/widget/<your-widget-name>' namespace instead.
     *
     * @return string
     */
    public function getLabel()
    {
        trigger_error(sprintf("%s::%s() is deprecated and will be removed in 5.5. Use 'label' snippet from 'backend/widget/<your-widget-name>' namespace instead.", __CLASS__, __METHOD__), E_USER_DEPRECATED);

        return $this->label;
    }

    /**
     * @deprecated Will be removed in 5.5. Use 'label' snippet from 'backend/widget/<your-widget-name>' namespace instead.
     *
     * @param string $label
     */
    public function setLabel($label)
    {
        trigger_error(sprintf("%s::%s() is deprecated and will be removed in 5.5. Use 'label' snippet from 'backend/widget/<your-widget-name>' namespace instead.", __CLASS__, __METHOD__), E_USER_DEPRECATED);

        $this->label = $label;
    }

    /**
     * @return
     */
    public function getViews()
    {
        return $this->views;
    }

    /**
     * @param  $views
     */
    public function setViews($views)
    {
        $this->views = $views;
    }

    /**
     * @param \Shopware\Models\Plugin\Plugin $plugin
     */
    public function setPlugin($plugin)
    {
        $this->plugin = $plugin;
    }

    /**
     * @return \Shopware\Models\Plugin\Plugin
     */
    public function getPlugin()
    {
        return $this->plugin;
    }
}
